//递归求 N 的阶乘
/*import java.util.Scanner;
public class Test {
    public static int factorial(int n) {
        if(n == 1) {
            return 1;
        }
        return n*factorial(n-1);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = factorial(n);
        System.out.println(ret);
    }
}*/


//递归求 1 + 2 + 3 + ... + 10
/*
public class Test {
    public static int factorial(int n) {
        if(n == 1) {
            return 1;
        }
        return n + factorial(n-1);
    }
    public static void main(String[] args) {
        int ret = factorial(10);
        System.out.println(ret);
    }
}*/


//按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4) （递归）
/*import java.util.Scanner;
public class Test {
    public static void sequentialPrinting(int a) {
        if(a/10 == 0) {
            ;
        } else {
            sequentialPrinting(a/10);
        }
        System.out.print((a%10) + " ");
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        sequentialPrinting(a);
    }
}*/


//写一个递归方法，输入一个非负整数，返回组成它的数字之和
/*import java.util.Scanner;
public class Test {
    public static int sumNumbers(int a) {
        if(a/10 == 0) {
            return 1;
        }
        return a%10 + sumNumbers(a/10);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int ret = sumNumbers(a);
        System.out.println(ret);
    }
}*/


//递归求斐波那契数列的第 N 项
/*import java.util.Scanner;
public class Test {
    public static int fibN(int n) {
        if(n == 1 || n ==2) {
            return 1;
        }
        return fibN((n-1)) + fibN((n-2));
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = fibN(n);
        System.out.println(ret);
    }
}*/


//递归求解汉诺塔问题
/*public class Test {
    public static void hanio(int n,char pos1,char pos2,char pos3) {
        if(n == 1) {
            move(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }
    public static void move(char pos1,char pos2) {
        System.out.print(pos1 + "->" + pos2 + " ");
    }
    public static void main(String[] args) {
        hanio(3,'A','B','C');
    }
}*/




//创建一个 int 类型的数组, 元素个数为 100, 并把每个元素依次设置为 1 - 100
/*import java.util.Arrays;
public class Test {
    public static void main(String[] args) {
        int[] arr = new int[100];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (i+1);
        }
        String ret = Arrays.toString(arr);
        System.out.println(ret);
    }
}*/


//实现一个方法 printArray, 以数组为参数, 循环访问数组中的每个元素, 打印每个元素的值.
/*import java.util.Arrays;
public class Test {
    public static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void main(String[] args) {
        int[] arr = { 1,2,3,4,5 };
        printArray(arr);
    }
}*/

//实现一个方法 transform, 以数组为参数, 循环将数组中的每个元素 乘以 2 ,
// 并设置到对应的数组元素上. 例如 原数组为 {1, 2, 3}, 修改之后为 {2, 4, 6}
import java.util.Arrays;
public class Test {
    public static void transform(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = 2*arr[i];
        }
    }
    public static void main(String[] args) {
        int[] arr = {1,2,3,4};
        transform(arr);
        System.out.println(Arrays.toString(arr));
    }
}